//
//  WmcTagTagView.swift
//  YPWatermarkCamera
//
//  Created by 赵新 on 2022/3/19.
//

import UIKit

class WmcTagTagView: WmcBaseTagView {


    override func makeUI() {
        super.makeUI()
        tagStyle = .tag
        defaultSize = CGSize(width: 255, height: 110)
        
        // 点
        contentView.addSubview(pointView)
        pointView.snp.makeConstraints { make in
            make.left.equalToSuperview()
            make.top.equalTo(18)
            make.size.equalTo(10)
        }
        
        // 添加三角
        contentView.addSubview(arrowImageView)
        arrowImageView.snp.makeConstraints { make in
            make.centerY.equalTo(pointView)
            make.left.equalTo(pointView.snp.right).offset(8)
            make.size.equalTo(CGSize(width: 15, height: 25))
        }
        
        contentView.addSubview(backgroundView)
        backgroundView.snp.makeConstraints { make in
            make.top.equalToSuperview()
            make.left.equalTo(arrowImageView.snp.right)
            make.bottom.right.equalToSuperview()
        }
        
        backgroundView.addSubview(textLabel)
        textLabel.snp.makeConstraints { make in
            make.top.equalTo(Wmc_standardEdge.top)
            make.left.equalTo(Wmc_standardEdge.left)
            make.bottom.equalTo(-Wmc_standardEdge.bottom)
            make.right.equalTo(-Wmc_standardEdge.right)
        }
    }
    
    lazy var pointView: UIView = {
        let view = UIView()
        view.layer.borderWidth = 2
        view.layer.cornerRadius = 5
        view.layer.shadowOffset = CGSize(width: 1, height: 2)
        view.layer.shadowRadius = 5
        view.layer.shadowOpacity = 0.4
        return view
    }()
    
    lazy var backgroundView: UIView = {
        let view = UIView()
        view.layer.cornerRadius = 5
        view.layer.masksToBounds = true
        return view
    }()
    
    lazy var arrowImageView: UIImageView = {
        let imageView = UIImageView(image: "edit_tag_tag_arrow".wmc_image)
        return imageView
    }()
    
    override func changeColor(_ color: WmcBaseTagView.Colors) {
        let uicolor = color.info.hexStr.yp.uiColor
        if color == .white {
            textLabel.textColor = .wmc_grayH2_323233
            pointView.layer.borderColor = UIColor.wmc_grayH2_323233.cgColor
        }else{
            textLabel.textColor = .white
            pointView.layer.borderColor = UIColor.white.cgColor
        }
        pointView.layer.shadowColor = pointView.layer.borderColor
        pointView.backgroundColor = uicolor
        
        let alphaColor = uicolor.yp.alpha(0.7)
        arrowImageView.yp.set(tintColor: alphaColor)
        backgroundView.backgroundColor = alphaColor
    }
}
